package 并发;

public class InterruptDemo {
    public static void main(String[] args) throws InterruptedException {
        final Thread sleepThread = new Thread() {
            @Override
            public void run() {
                try {
                    System.out.println("59");
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                super.run();
            }
        };
        Thread busyThread = new Thread() {
            @Override
            public void run() {
                while (true) ;
            }
        };


        sleepThread.start();
        busyThread.start();
        Thread.sleep(3000);
        sleepThread.interrupt();
        busyThread.interrupt();
        while (sleepThread.isInterrupted()) {
            System.out.println("55");
        }
        ;
        System.out.println("sleep isInterrupted：" + sleepThread.isInterrupted());
        System.out.println("busy isInterrupted：" + busyThread.isInterrupted());
    }
}
